package net.zjitc.service.impl;

import net.zjitc.dao.CategoryDao;
import net.zjitc.dao.CategorySecondDao;
import net.zjitc.dao.impl.CategoryDaoImpl;
import net.zjitc.dao.impl.CategorySecondDaoImpl;
import net.zjitc.pojo.Category;
import net.zjitc.pojo.CategorySecond;
import net.zjitc.service.CategoryService;

import java.util.List;

/**
 * Created by Administrator on 2017/11/19.
 */
public class CategoryServiceImpl implements CategoryService {
    CategoryDao dao = new CategoryDaoImpl();
    CategorySecondDao csDao=new CategorySecondDaoImpl();
    public List<Category> findAll() {
        return dao.findAll();
    }

    public int insert(Category category) {
        return dao.insert(category);
    }

    public int delete(String cid) {
        return dao.delete(cid);
    }

    public int update(Category category) {
        return dao.update(category);
    }

    public Category findByCid(String cid) {
        return dao.findByCid(cid);
    }
    @Override
    public List<Category> findAllCate() {
        List<Category> list=dao.findAllCate();
        for (Category c:list) {
            List<CategorySecond> cslist=csDao.fingByCid(c.getCid());
            c.setCategorySecondList(cslist);
        }
        return list;
    }
}
